package logic

import (
	"context"
	"ykone/models/mysql"

	"ykone/ykonerpc/internal/svc"
	"ykone/ykonerpc/ykonerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ProduceDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewProduceDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ProduceDelLogic {
	return &ProduceDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ProduceDelLogic) ProduceDel(in *ykonerpc.ProduceDelRequest) (*ykonerpc.ProduceDelResponse, error) {

	var produce mysql.Produce
	mysql.DB.Debug().Where("id = ?", in.Id).Delete(&produce)

	return &ykonerpc.ProduceDelResponse{Id: int64(produce.ID)}, nil
}
